import { _decorator, Component, Node, EventMouse, Sprite, SpriteRenderer, tween, Vec3 } from 'cc';
import { ParamUI } from './ParamUI';
import { plog } from '../Utils/Tools';
const { ccclass, property } = _decorator;

@ccclass('UiCover')
export default class UiCover extends Component {

    @property(Node)
    NodeBlack: Node = null;
    @property(Node)
    NodeLoading: Node = null;


    onLoad(): void {
        this.NodeBlack.active = false
        this.NodeLoading.active = false

        this.node.on(Node.EventType.TOUCH_END, this.onBackClick, this);
    }
    start() {

    }
    public Set(type: number = 0, delay: number = 2000) {
        switch (type) {
            case 0:
                {
                }
                break;
            case 1:
                {
                    this.NodeBlack.active = true
                }
                break;
            case 2:
                {
                    setTimeout(() => {
                        this.NodeBlack.active = true
                        this.NodeLoading.active = true
                        tween(this.NodeLoading)
                            .by(1, { angle: -360 }, {
                                easing: 'quadInOut'  // 线性缓动，使旋转速度恒定
                            }).repeat(Infinity)
                            .start();
                    }, delay);
                }
                break;
            case 3:
                {
                    this.NodeBlack.active = false
                    setTimeout(() => {
                        this.NodeBlack.active = true
                    }, delay);
                }
                break;
        }
    }
    // public Hide() {
    //     this.node.active = false;
    //     this.node.off(Node.EventType.TOUCH_END, this.onTouchCover, this);
    // }
    onDestroy() {
        this.node.off(Node.EventType.TOUCH_END, this.onBackClick, this);
    }

    onBackClick(evt) {
        evt.bubbles = false
    }


    update(deltaTime: number) {

    }
}


